package com.yao.smy.service;

import com.yao.smy.domain.VisitorDeviceRecord;
import com.yao.smy.repository.VisitorDeviceRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class VisitorDeviceRecordServiceImpl implements VisitorDeviceRecordService {

    @Autowired
    private VisitorDeviceRecordRepository visitorDeviceRecordRepository;

    @Override
    public void addVisitorDeviceRecord(VisitorDeviceRecord record) {
        visitorDeviceRecordRepository.save(record);
    }

    @Override
    public void deleteVisitorDeviceRecord(Long id) {
        visitorDeviceRecordRepository.deleteById(id);
    }

    @Override
    public void updateVisitorDeviceRecord(VisitorDeviceRecord record) {
        visitorDeviceRecordRepository.save(record);
    }

    @Override
    public VisitorDeviceRecord getVisitorDeviceRecord(Long id) {
        return visitorDeviceRecordRepository.findById(id).orElse(null);
    }

    @Override
    public List<VisitorDeviceRecord> getAllVisitorDeviceRecords() {
        return visitorDeviceRecordRepository.findAll();
    }

    @Override
    public List<VisitorDeviceRecord> getVisitorDeviceRecordsByVisitorIdCard(String visitorIdCard) {
        return visitorDeviceRecordRepository.findByVisitorIdCard(visitorIdCard);
    }

    @Override
    public List<VisitorDeviceRecord> getVisitorDeviceRecordsByDeviceIp(String deviceIp) {
        return visitorDeviceRecordRepository.findByDeviceIp(deviceIp);
    }
}